<!DOCTYPE html [
    <!ENTITY nbsp "&#160;">
    <!ENTITY bull "&#8226;">
    <!ENTITY copy "&#169;">
]>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" 
	xmlns:s="http://sduept.security.el/func">
<h:head>
	<title>一次设备绑定</title>
</h:head>
		<link rel="stylesheet"
			href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<h:form id="form1">
		<p:dialog widgetVar="bindDialog" header="一次设备选择" id="bindDialog" modal="true" width="500" height="200">
			<p:toolbar>
				<f:facet name="left">
		        	<p:commandButton value="保存" actionListener="#{unbindProtectDialogController.saveBindInfo}" 
		        		onclick="PF('bindDialog').hide()" update="form1:incorProTable form1:msg" icon="ui-icon-disk" />
				</f:facet>
			</p:toolbar>
			<p:panelGrid cellpadding="5"
					style="margin-top:10px; width:100%;border:0">
					<p:row rowspan="1">
						<p:column>
							<h:outputText value="变电站：" />
						</p:column>
						<p:column colspan="3">
						<p:autoComplete placeholder="输入拼音首字母可查询" 
							value="#{unbindProtectDialogController.station}"
							completeMethod="#{cimUtilController.completeCimStation}" dropdown="true"/>
						</p:column>
					</p:row>
					<p:row rowspan="1">
						<p:column>
							<h:outputText value="一次设备：" />
						</p:column>
						<p:column colspan="2">
							<p:inputText style="border:none" readonly="true" id="deviceName" value="#{unbindProtectDialogController.deviceName}"/>
						</p:column>
						<p:column colspan="1"> 
							<p:commandButton value="选择" actionListener="#{unbindProtectDialogController.getEquipmentByStation}">
								<p:ajax event="dialogReturn" update="deviceName" listener="#{unbindProtectDialogController.onEquDialogChosenListener}" />
							</p:commandButton>
						</p:column>
					</p:row>
			</p:panelGrid>
		</p:dialog> 
			<p:growl id="msg" showDetail="true" />
			<p:toolbar>
				<f:facet name="left">
		        	<p:commandButton value="关联变电站" update="form1:bindDialog" oncomplete="PF('bindDialog').show()" 
		        	actionListener="#{unbindProtectDialogController.updateStationName}" icon="ui-icon-pencil" 
		        	rendered="#{s:hasPermission(session,'jcsj_bhsbtz_glbdz')}"/>
		        	<p:commandButton value="关联一次设备" update="bingPrimForm:bingPrimDlg form1:msg" oncomplete="PF('bingPrimDlg').show()" 
		        	actionListener="#{unbindProtectDialogController.checkSelected}" icon="ui-icon-pencil" 
		        	rendered="#{s:hasPermission(session,'jcsj_bhsbtz_glycsb')}"/>
				</f:facet>
			</p:toolbar>
			<p:dataTable id="incorProTable" var="incorrectPro" value="#{unbindProtectDialogController.currentDeviceProList}" 
			rowKey="#{incorrectPro.id}" selection="#{unbindProtectDialogController.selects}" 
			emptyMessage="无记录" sortBy="#{incorrectPro.protectedType}">
				<p:ajax event="cellEdit" />
				<p:column selectionMode="multiple" style="width:40px;text-align:center"/>
				<p:column width="150" headerText="保信变电站（参考）">
					<h:outputText value="#{incorrectPro.privateStationName}" />
				</p:column>
				<p:column width="150" headerText="变电站">
					<h:outputText value="#{incorrectPro.substationName}" />
				</p:column>
				<p:column width="350" headerText="保护名称">
					<h:outputText value="#{incorrectPro.name}" />
				</p:column>
				<p:column width="150" headerText="被保护设备">
					<h:outputText value="#{incorrectPro.protectedName}" />
				</p:column>
				<p:column width="100" headerText="被保护类型">
					<h:outputText value="#{incorrectPro.protectedType}" />
				</p:column>
				<p:column width="80" headerText="类型">
					<p:outputLabel value="#{incorrectPro.type}" />
				</p:column>
				<p:column headerText="保护型号">
					<p:outputLabel value="#{incorrectPro.devType}" />
				</p:column>
			</p:dataTable>
	</h:form>
	<!-- 关联一次设备 -->
	<h:form id="bingPrimForm">
		<p:dialog widgetVar="bingPrimDlg" header="一次设备关联" modal="true"
				id="bingPrimDlg" width="420" height="370">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton id="editSaveBtn" value="保存"
							icon="ui-icon-disk"
							update="form1:incorProTable form1:msg"
							oncomplete="PF('bingPrimDlg').hide()"
							actionListener="#{unbindProtectDialogController.update}" />
					</f:facet>
				</p:toolbar>
				<p:outputPanel id="editDetail" style="text-align:center;">
					<p:panelGrid columns="2">
						<h:outputText value="保护名称" />
						<p:inputText value="#{unbindProtectDialogController.selected.name}"
							style="width:100%" label="protectedName"></p:inputText>
						<h:outputText value="保护类型" />
						<p:selectOneMenu
							value="#{unbindProtectDialogController.selected.type}"
							style="width:90%">
							<f:selectItems value="#{unbindProtectDialogController.proKinds}"
								var="type" itemLabel="#{type}" itemValue="#{type}" />
						</p:selectOneMenu>

						<h:outputText value="变电站" />
						<p:autoComplete placeholder="输入拼音首字母可查询" 
							value="#{unbindProtectDialogController.station}"
							completeMethod="#{cimUtilController.completeCimStation}" dropdown="true"/>
						<!-- <p:autoComplete id="selectStation_auto" scrollHeight="400"
							dropdown="true"
							value="#{unbindProtectDialogController.station}"
							completeMethod="#{unbindProtectDialogController.completeStationNames}">
							<p:ajax event="itemSelect"
								listener="#{unbindProtectDialogController.onStationItemSelect}"
								update="selectEquipment msg" />
						</p:autoComplete> -->
						<h:outputText value="一次设备名称" />
						<!-- <p:autoComplete id="selectEquipment" scrollHeight="400"
							dropdown="true"
							value="#{unbindProtectDialogController.selected.protectedName}"
							completeMethod="#{unbindProtectDialogController.completeEquipmentNames}">
							<p:ajax event="itemSelect"
								listener="#{unbindProtectDialogController.onProtectItemSelect}"
								update="incorrectProForm:msg" />
						</p:autoComplete> -->
						<p:row>
							<p:inputText readonly="true" id="deviceName" value="#{unbindProtectDialogController.selected.protectedName}"/>
							<p:commandButton value="选择" actionListener="#{unbindProtectDialogController.getEquipmentByStation}">
								<p:ajax event="dialogReturn" update="deviceName" listener="#{unbindProtectDialogController.onEquDialogChosenListener}" />
							</p:commandButton>
						</p:row>
						<h:outputText value="一次设备类型" />
						<p:selectOneMenu
							value="#{unbindProtectDialogController.selected.protectedType}"
							style="width:90%">
							<!-- <p:ajax event="change"
								listener="#{unbindProtectDialogController.onProtectedTypeChange}"
								update="selectEquipment"></p:ajax> -->
							<f:selectItems
								value="#{unbindProtectDialogController.protectedTypes}"
								var="protectedType" itemLabel="#{protectedType}"
								itemValue="#{protectedType}" />
						</p:selectOneMenu>
						<h:outputText value="保护型号:" />
						<p:inputText value="#{unbindProtectDialogController.selected.devType}"
							style="width:100%" label="protectedName"></p:inputText>
						<!-- <p:autoComplete
							value="#{unbindProtectDialogController.selected.devType}"
							style="width:100%"
							completeMethod="#{unbindProtectDialogController.completeDevTypes}"
							scrollHeight="400" /> -->
						<h:outputText value="生产厂家" />
						<p:autoComplete scrollHeight="400" dropdown="true"
							value="#{unbindProtectDialogController.selected.devManufacturer}"
							completeMethod="#{unbindProtectDialogController.completeDevManufacturer}">
						</p:autoComplete>
					</p:panelGrid>
				</p:outputPanel>
			</p:dialog>
	</h:form>
</html>